<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.awk</title>
<meta name="generator" content="KF5::SyntaxHighlighting (AWK)"/>
</head><body style="color:#1f1c1b"><pre>
<span style="color:#898887;">#!/usr</span>
<span style="color:#898887;"># AWK hl test</span>

<span style="color:#898887;"># </span><span style="color:#0057ae;background-color:#e0e9f8;">BEGIN</span><span style="color:#898887;"> and </span><span style="color:#0057ae;background-color:#e0e9f8;">END</span><span style="color:#898887;"> are also matched as patterns</span>
BEGIN {
	p = <span style="color:#b08000;">0</span>;
}

<span style="color:#006e28;">/</span><span style="color:#ff5500;">some pattern</span><span style="color:#006e28;">/</span> {
	p++;
}

<span style="color:#898887;"># / inside brackets is not considered end of expression</span>
<span style="color:#898887;"># a loose division operator (/) is not mismatched as a pattern.</span>
<span style="color:#0057ae;">$1</span> =~ <span style="color:#006e28;">/[^</span><span style="color:#ff5500;">abc/</span><span style="color:#006e28;">]</span><span style="color:#ff5500;">def</span><span style="color:#006e28;">/</span> || b == <span style="color:#b08000;">3</span> / <span style="color:#b08000;">5</span> {

	<span style="color:#644a9b;">gsub</span> ( <span style="color:#644a9b;font-weight:bold;">FILENAME</span> );

}

<span style="color:#898887;"># </span><span style="color:#ca9219;background-color:#451e1a;font-weight:bold;">TODO</span><span style="color:#898887;"> and </span><span style="color:#ca9219;background-color:#451e1a;font-weight:bold;">FIXME</span><span style="color:#898887;"> also work in comments in Awk.</span>

<span style="color:#898887;"># Also backslash in patterns works.</span>
<span style="color:#006e28;">/\</span><span style="color:#3daee9;">/</span><span style="color:#ff5500;">usr</span><span style="color:#006e28;">\</span><span style="color:#3daee9;">/</span><span style="color:#ff5500;">bin</span><span style="color:#006e28;">\</span><span style="color:#3daee9;">/</span><span style="color:#ff5500;">awk</span><span style="color:#006e28;">/</span> { <span style="font-weight:bold;">print</span> <span style="color:#bf0303;">&quot;This is me&quot;</span>; }

END {
	<span style="font-weight:bold;">print</span> p;
}

<span style="font-weight:bold;">function</span> myfunc()
{
    <span style="font-weight:bold;">print</span> <span style="color:#b08000;">42</span>
}

<span style="color:#006e28;">/</span><span style="color:#ff5500;">abc</span><span style="color:#006e28;">/</span>,<span style="color:#006e28;">/</span><span style="color:#ff5500;">a</span><span style="color:#006e28;">[</span><span style="color:#ff5500;">b</span><span style="color:#006e28;">]</span><span style="color:#ff5500;">c</span><span style="color:#006e28;">/</span>{
	<span style="color:#898887;"># parameter with a regex</span>
	<span style="font-weight:bold;">if</span> (<span style="color:#644a9b;">match</span>(<span style="color:#0057ae;">$0</span>, <span style="color:#006e28;">/</span><span style="color:#ff5500;">a</span><span style="color:#006e28;">/</span>)) {}

	<span style="color:#bf0303;">&quot;x</span><span style="color:#3daee9;">\a</span><span style="color:#bf0303;">x</span><span style="color:#3daee9;">\n</span><span style="color:#bf0303;">x</span><span style="color:#3daee9;">\</span><span style="color:#bf0303;text-decoration:underline;">e</span><span style="color:#bf0303;">x</span><span style="color:#3daee9;">\</span><span style="color:#bf0303;text-decoration:underline;">z</span><span style="color:#bf0303;">x</span><span style="color:#3daee9;">\023</span><span style="color:#bf0303;">x</span><span style="color:#3daee9;">\2</span><span style="color:#bf0303;">x</span><span style="color:#3daee9;">\xff</span><span style="color:#bf0303;">x</span><span style="color:#3daee9;">\xFf\xa</span><span style="color:#bf0303;">x</span><span style="color:#3daee9;">\12</span><span style="color:#bf0303;">x&quot;</span>

	a =~ <span style="color:#006e28;">/[</span><span style="color:#0095ff;font-weight:bold;">[:alpha:]</span><span style="color:#006e28;">]/</span>
	a =~ <span style="color:#006e28;">/[</span><span style="color:#ff5500;">xx</span><span style="color:#0095ff;font-weight:bold;">[:alpha:]</span><span style="color:#ff5500;">xx</span><span style="color:#006e28;">]/</span>
	a =~ <span style="color:#006e28;">/[</span><span style="color:#ff5500;">a</span><span style="color:#006e28;">-</span><span style="color:#ff5500;">z</span><span style="color:#0095ff;font-weight:bold;">[:alpha:]</span><span style="color:#ff5500;">xx-</span><span style="color:#006e28;">]/</span>
	a =~ <span style="color:#006e28;">/[</span><span style="color:#ff5500;">]a</span><span style="color:#006e28;">]/</span>
	a =~ <span style="color:#006e28;">/[</span><span style="color:#ff5500;">-a</span><span style="color:#006e28;">]/</span>
	a =~ <span style="color:#006e28;">/[^</span><span style="color:#ff5500;">]a</span><span style="color:#006e28;">]/</span>
	a =~ <span style="color:#006e28;">/[^</span><span style="color:#ff5500;">-a</span><span style="color:#006e28;">]/</span>
	a =~ <span style="color:#006e28;">/[</span><span style="color:#ff5500;">a</span><span style="color:#006e28;">]</span><span style="color:#ff5500;">a</span><span style="color:#006e28;">\</span><span style="color:#3daee9;">/</span><span style="color:#006e28;">\</span><span style="color:#3daee9;">n</span><span style="color:#006e28;">/</span>
	<span style="color:#898887;"># incomplete regex</span>
	a =~ <span style="color:#006e28;">/[</span><span style="color:#ff5500;">xx</span><span style="color:#0095ff;font-weight:bold;">[:</span><span style="color:#006e28;">alph</span>
	a = <span style="color:#b08000;">23.2</span>
}
</pre></body></html>
